package top.zhangjianyong.tools.remind.strategy;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import top.zhangjianyong.tools.entity.RemindItem;
import top.zhangjianyong.tools.utils.RemindUtil;

import java.time.LocalDateTime;

/**
 * @author ： zhangjianyong
 * @date ： 2022/10/9 4:22 PM
 */
@Component
public class CircleRemindStrategy implements RemindStrategy {

    @Autowired
    private RemindUtil remindUtil;

    @Override
    public String type() {
        return "循环间隔";
    }

    @Override
    public void remind(RemindItem remindItem) throws Exception {
        int minute = LocalDateTime.now().getMinute();
        if (minute % 5 == 0) {
            remindUtil.sendEmail(remindItem);
        }
    }

    @Override
    public boolean reset() {
        return false;
    }
}
